#ifndef QD3DCONTEXT_H
#define QD3DCONTEXT_H
#include "qd3d_global.h"
#include <d3d11.h>
#include <QObject>
#include <glm/glm.hpp>
#include <QStack>

#define QD3D_WORLD_MAT_MODE 0
#define QD3D_VIEW_MAT_MODE 1
#define QD3D_PROJ_MAT_MODE 2

class QD3D_EXPORT QD3DContext : QObject
{

	Q_OBJECT

public:

	D3D_DRIVER_TYPE driverType;
	D3D_FEATURE_LEVEL featureLevel;
	ID3D11Device *pDevice;
	ID3D11DeviceContext *pImmediateContext;
	IDXGISwapChain *pSwapChain;
	ID3D11RenderTargetView *pRenderTargetView;
	ID3D11DepthStencilView *pDepthStencilView;

	ID3D11Buffer *pMatrixDxConstBuf;
	struct MatrixConstVars
	{
		glm::mat4 vals[3];
	} matrixConstVars;
	QStack< glm::mat4 > matStacks[3];
	int curMode;

	QD3DContext (HWND hWnd);
	~QD3DContext ();

	static QD3DContext *cur ();
	static void lockCur (QD3DContext *pContext);
	static void releaseCur (QD3DContext *pContext);

private:

	static QD3DContext *_pCurrent;

	LRESULT _initialize (HWND hWnd);
	void _cleanup ();
};

#endif // QD3DCONTEXT_H
